﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;

namespace BarManager.Core.Entity
{
    [DataContract]
    public class Producto 
    {        
        [DataMember]
        public int Id { get; set; }

        [Required]
        [DataMember]
        public int CategoriaId { get; set; }

        [DataMember]
        public int? ProveedorId { get; set; }

        [Required]
        [StringLength(50)]
        [DataMember]
        public string Nombre { get; set; }

        [Required]
        [RegularExpression(@"^([0-9]*\,?[0-9]+|[0-9]+\,?[0-9]*)?$",
            ErrorMessage = "Precio Vta. invalido (0,00)")]
        [DataType(DataType.Currency)]
        [Display(Name = "Precio Vta.")]
        [DataMember]
        public decimal? PrecioVenta { get; set; }

        [RegularExpression(@"^([0-9]*\,?[0-9]+|[0-9]+\,?[0-9]*)?$",
            ErrorMessage = "Precio Costo invalido (0,00)")]
        [DataType(DataType.Currency)]
        [Display(Name = "Precio Costo")]
        [DataMember]
        public decimal? PrecioCosto { get; set; }

        [Display(Name = "Controlar Stock")]
        [DataMember]
        public bool ControlarStock { get; set; }

        [Display(Name = "Stock Minimo")]
        [Range(typeof(Int32), "1", "1000")]
        [DataMember]
        public int? StockMinimo { get; set; }

        [Display(Name = "Stock")]
        [Range(typeof(Int32), "0", "1000")]
        [DataMember]
        public int? Stock { get; set; }

        [DataMember]
        public virtual Proveedor Proveedor { get; set; }

        [DataMember]
        public virtual Categoria Categoria { get; set; }
                
        [DataMember]
        public virtual ICollection<PromocionDetalle> PromocionDetalleList { get; set; }

        public Producto()
        {            
            this.PromocionDetalleList = new List<PromocionDetalle>();
        }
    }
}
